package com.yc.jpyy.mobile.controller;


import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yc.jpyy.base.bean.RestResponse;
import com.yc.jpyy.base.config.Config;
import com.yc.jpyy.base.controller.BaseController;
import com.yc.jpyy.mobile.dao.BizDao;
import com.yc.jpyy.mobile.service.BizService;

@Controller
@RequestMapping(value = "/student")
public class GetLearnTimeController extends BaseController {

	private static Logger logger = LoggerFactory.getLogger(GetLearnTimeController.class);
	
	@Autowired
	private BizService bizService;
	
	@Autowired
	private BizDao bizDao;

	/**
	 * 获取学时
	 */
	@SuppressWarnings("finally")
	@RequestMapping(value = "/getLearnTime", method = RequestMethod.POST, produces = "application/json; charset=utf-8")
	public @ResponseBody String getLearnTime(HttpServletRequest request){
		RestResponse response = new RestResponse();
		try {
			// 用户Id
			String studentId = request.getParameter("studentId");
			String imgUrl = Config.getImageAddress();
			if((null!=studentId&&!studentId.equals(""))){
				Map<String, Object> learnTimeInfo = bizDao.getLearnTimeByStuId(studentId,imgUrl);
				if(null != learnTimeInfo && learnTimeInfo.size()>0){
					response.setData(learnTimeInfo);
				}else{
					response.setErrorcode(1);
					response.setMessage("无学时信息！");
				}	
			}else{  
				response.setErrorcode(1);
				response.setMessage("缺少必填字段！");
			}
		} catch (Exception e) {
			logger.info("学时查询:"+ e.toString());
			response.setErrorcode(1);
			response.setMessage("学时查询失败！");
			errorHandler(e, response, logger);
		}finally{
			return response.toJSON();	
		}

	}

	
	
	
}
